<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
    <title>测试</title>
    <script src="js/jquery/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="js/json/json2.js" type="text/javascript"></script>
	<script src="js/handlebars/handlebars-v1.3.0.min.js" type="text/javascript"></script>
	<script src="js/light/light.js" type="text/javascript"></script>
	<script src="js/light/light.msg.js" type="text/javascript"></script>
	<script src="js/light/light.ajax.js" type="text/javascript"></script>
	
</head>
<body>
	
	<h1> session test</h1>
	session set test (login)
	<input type="button" id="btn_test_session_set" name="session set test"/>
	session get test
	<input type="button" id="btn_test_session_get" name="session get test"/>
	session set test (logout)
	<input type="button" id="btn_test_session_set2" name="session set2 test"/>
	<br/>
	<h1> ajax get/post test</h1>
	http get test
	<input type="button" id="btn_test_ajax" name="ajax get test"/>
	http post test
	<input type="button" id="btn_test_ajax_post" name="ajax post test"/>
	<br/>
	<h1>ajax tpl load test</h1>	
	get template html
	<input type="button" id="btn_test_ajax_tpl" name="tpl load test"/>
	<div id ="entry"></div>
	
	
</body>
</html>
<script id="entry-template" type="text/x-handlebars-template">
<h2 style="color:red">
{{example}}
</h2>
</script>

<script type="text/javascript">
$(function(){

    $("#btn_test_session_set").click(function(){
    	var cmd = new Object();
    	cmd['id']='nearshop1';
    	cmd['password']='password1';
    	light.ajax.postJson("/login/login",cmd,function(json,state){
    		if(state){
    			alert(json.bean);
    		}else{
    			alert(json.head.msg);
    		}
    	});
	});
    $("#btn_test_session_set2").click(function(){
    	
    	light.ajax.postJson("/login/logout",{},function(json,state){
    		if(state){
    			alert(json.bean);
    		}else{
    			alert(json.head.msg);
    		}
    	});
	});
    
    
    $("#btn_test_session_get").click(function(){
    	light.ajax.getJson("/test/get/12345/lirn",function(json,state){
    		if(state){
    			alert("success");
    		}else{
    			alert("error");
    		}
    	});
	});
    /////////////////////////////////////////
	
    $("#btn_test_ajax").click(function(){
    	light.ajax.getJson("/test/get/12345/lirn",function(json,state){
    		if(state){
    			alert("success");
    		}else{
    			alert("error");
    		}
    	});
	});
    
    $("#btn_test_ajax_post").click(function(){
    	var cmd = new Object();
    	cmd['id']="你好！json";
    	light.ajax.postJson("/test/post",JSON.stringify(cmd),function(json,state){
			if(state){
				alert("success");
				alert(json);
			}else{
				alert("fail");
			}
		});
	});
    
    $("#btn_test_ajax_tpl").click(function(){
    	var cmd = new Object();
    	cmd['example']="hello,you";
		light.ajax.loadTemp($("#entry"), $("#entry-template"), {example:"hello,you"});
	});
    
});
</script>